package com.song.ejf.util;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.map.ObjectMapper;


public class JSONUtil {
	static Log log = LogFactory.getLog(JSONUtil.class);
	
	public static String convertObj2Json(Object obj){
		ObjectMapper mapper = new ObjectMapper();
		try {
			String temp = mapper.writeValueAsString(obj);
			if(StringUtils.isNotBlank(temp)){
				return temp.replaceAll("\"", "'");
			}else{
				return null;
			}
		} catch (Exception e) {
			log.error("对象转json异常.",e);
		} 
		return null;
	}
}
